<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/html/js/axios.min.js"></script>
    <script src="/html/js/ajax.js"></script>
    <script src="/html/js/util.js"></script>
    <script>
        let orderId = "";
        window.onload = function () {
            orderId = getQuery("orderId");
            init();
        }

        async function init() {
            let info = await ajaxGet("/order/findById", {id: orderId});
            let str = `<span style="font-size: 10px;font-weight: bolder">订单编号:${info.id}</span><br>
                     <span style="font-size: 10px;font-weight: bolder">收货人:${info.name}</span><br>
                     <span style="font-size: 10px;font-weight: bolder">送货地址:${info.address}</span><br>
                     <span style="font-size: 10px;font-weight: bolder">收货人电话:${info.phone}</span><br>
                     <span style="font-size: 10px;font-weight: bolder">下单时间:${info.date}</span><br>
                    <span style="font-size: 10px;font-weight: bolder">订单总价:${info.money}</span><br>
                    <span style="font-size: 10px;font-weight: bolder">订单状态:${info.status}</span><br>`;
            getObject("orderDetailsDiv").innerHTML = str;

            let detaoStr = "";
            console.log(info.list);
            for (let i=0;i<info.list.length;i++){
                let obj=info.list[i];
                detaoStr+=`<tr><td>${obj.id}</td>
                           <td>${obj.product.name}</td>
                           <td>${obj.product.money}</td>
                           <td>${obj.num}</td></tr>`
            }
            getObject("showOrderDetaibody").innerHTML=detaoStr;
        }

        async function beak(){
            let userBean = await ajaxGet("/user/getLoginUser");
            location.href=`/html/custom/showOrder.html?userId=${userBean.id}`
        }
    </script>
</head>
<body>
<div style="margin-left: 100px;margin-top: 100px">
    <div id="orderDetailsDiv"></div>
    <div style="margin-top: 50px"><span style="font-size: 20px;">订单明细</span></div>
    <div >
        <table border="1" cellpadding="0">
            <thead>
            <tr>
                <th>商品编号</th>
                <th>商品名</th>
                <th>单价</th>
                <th>购买数量</th>
            </tr>
            </thead>
            <tbody id="showOrderDetaibody"></tbody>
        </table>
    </div>
    <input type="button" value="返回" onclick="beak()">
</div>
</body>
</html>